<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h2>Array</h2>
        <div>
            {{arr}}
        </div>
        <button @click="changearr">修改数组的值</button>
        <h2>Object</h2>
        <div>
            {{user}}
        </div>
        <button @click="changeobj">修改对象里的值</button>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script>
        let vm = new Vue({
            el:'#app',
            data:{
                arr:[1,2,3],
                user:{a:1}
            },
            methods:{
                changearr(){
                    // set(要修改的数组，修改的索引下标，修改的值)
                    this.$set(this.arr,1,888)
                },
                changeobj(){
                     // set(要修改的对象，修改的属性，修改的值)
                    this.$set(this.user,"b","王二麻")
                }
            }
        });
    </script>
</body>
</html>